

const isDev = true

// const PRODIPADDR='182.43.42.133:7227'
const PRODIPADDR='agent.51gpt.cloud:7227'
const DEVIPADDR='127.0.0.1:7227'

// const isProd = process.env.NODE_ENV === 'production'
const HTTP_PROTOCOL = isDev ? 'http' : 'https'
const WS_PROTOCOL = isDev ? 'ws' : 'wss'
const IPADDR = isDev ?  DEVIPADDR : PRODIPADDR
export const MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB

// 导出配置
const BASE_URL = `${HTTP_PROTOCOL}://${IPADDR}`;
const WS_URL = `${WS_PROTOCOL}://${IPADDR}/ws`;
// export const TENANT_URN="tenants/1"
export const APPID="wx116c9e9a670b3ac1"

export const getBaseUrl = () => {
    let url=''
    console.log("is h5")
    const protocol = window.location.protocol  // 包含冒号 "http:" 或 "https:"
    console.log("is h5,", protocol)

    const hostname = window.location.hostname  // 主机名
    const port = window.location.port         // 端口号
    
    // 如果有端口号就加上端口号
    url= port ? 
      `${protocol}//${hostname}:${port}` : 
      `${protocol}//${hostname}`
    // url=BASE_URL
  
    // 其他平台
    console.log('base url:',url)
    return url
}

export const getWssUrl = () => {
    let url=''
    const protocol = window.location.protocol  // 包含冒号 "http:" 或 "https:"
    const hostname = window.location.hostname  // 主机名
    const port = window.location.port         // 端口号

    const wsProtocol = protocol === 'https:' ? 'wss:' : 'ws:'

    url = port ? 
    `${wsProtocol}//${hostname}:${port}/ws` : 
    `${wsProtocol}//${hostname}/ws`
    // 其他平台
    console.log('ws url:',url)
    return url
}